package cn.com.dhc.danlu.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.fragment.AlwaysBuyFragment;
import cn.com.dhc.danlu.widget.PagerSlidingTabStrip;

/**
 * author: 吴海洋(<a href="mailto:wuhaiyang@danlu.com">wuhaiyang@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2016-08-05 20:36<br/>
 *
 * <p>
 * 我的常购界面
 * </p>
 */
public class AlwaysBuyActivity extends DefaultFragmentActivity {
    private PagerSlidingTabStrip mPagerSlidingTabStrip;
    private ViewPager mViewPager;

    //    private DanluTaskProxy danluTaskProxy;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dl_activty_tabfragment);
        initView();
        MyPagerFragmentAdapter fragmentAdapter = new MyPagerFragmentAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(fragmentAdapter);
        mPagerSlidingTabStrip.setViewPager(mViewPager);
    }

    private void initView() {
        mPagerSlidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs);
        mViewPager = (ViewPager) findViewById(R.id.view_pager);
    }

    private class MyPagerFragmentAdapter extends FragmentPagerAdapter {
        private String[] mTitles;

        MyPagerFragmentAdapter(FragmentManager fm) {
            super(fm);
            mTitles = new String[]{getResources().getString(R.string.hot_sell), getResources().getString(R.string.off_goods)};
        }

        @Override
        public Fragment getItem(int position) {
            return AlwaysBuyFragment.newInstance(position);
        }

        @Override
        public int getCount() {
            return mTitles.length;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return mTitles[position];
        }
    }
}